from collections import defaultdict


class Solution:
    def numRabbits(self, answers):
        """
        :type answers: List[int]
        :rtype: int
        """
        count = defaultdict(int)
        for x in answers:
            count[x] += 1

        total = 0
        for x in count:
            groups = (count[x] + x) // (x + 1)
            total += groups * (x + 1)

        return total